﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace FanaticRock.Core.Helpers
{
    public static class CollectionHelper
    {
        public static void UpdateIndex<T>(IList<T> coll, Action<T, int> setIndexAction)
        {
            if (setIndexAction == null) return;

            var i = 1;
            foreach (var item in coll)
            {
                setIndexAction(item, i);
                i++;
            }
        }


        public static void UpdateIndex<T>(IList<T> coll, Action<T, int> setIndexAction, int startIndex)
        {
            if (setIndexAction == null) return;

            var i = startIndex;
            foreach (var item in coll)
            {
                setIndexAction(item, i);
                i++;
            }
        }

    }
}
